package io.gitee.yxsnake.framework.translation.core.impl;

import io.gitee.yxsnake.framework.core.domain.Result;
import io.gitee.yxsnake.framework.core.utils.ResultUtils;
import io.gitee.yxsnake.framework.resource.api.RemoteFileService;
import io.gitee.yxsnake.framework.translation.annotation.TranslationType;
import io.gitee.yxsnake.framework.translation.constant.TransConstant;
import io.gitee.yxsnake.framework.translation.core.TranslationInterface;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;

/**
 * @author snake
 * @description OSS翻译实现
 * @since 2024/11/3 14:00
 */
@AllArgsConstructor
@TranslationType(type = TransConstant.OSS_ID_TO_URL)
public class OssUrlTranslationImpl implements TranslationInterface<String> {

    @Resource
    private RemoteFileService remoteFileService;

    @Override
    public String translation(Object key, String other) {
        final Result<String> result = remoteFileService.selectUrlByIds(key.toString());
        final String data = ResultUtils.getResultData(result);
        return data;
    }
}

